import os
import config_json
import subprocess
import getpath
import myglobal
import zipfile, os
def copy_qss():
	src_path=os.path.join(getpath.getpath(),"qss")
	des_path=os.path.join(getpath.getpath(),"dist","report_icp","qss")
	args = ["xcopy.exe", "/Y","/I", src_path, des_path]
	subprocess.Popen(args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
	                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
def main():
	myglobal.initpath=getpath.getpath()
	config_json.read_setting()
	ver=int(config_json.setting["version"])
	ver+=1
	config_json.setting["version"]=str(ver)
	config_json.write_setting()
	cmd=r"""e:\python38\scripts\pyinstaller report_spec.spec"""
	os.system(cmd)
	# copy_qss()
def f1():
	config_json.read_setting()
	ver=config_json.setting["version"]
	filename=os.path.join(getpath.getpath(),"dist",f"report_spec_{ver}.zip")
	zipFile = zipfile.ZipFile(filename, 'w')
	path=r'./dist/report_spec'
	# path=r'./dist/example'
	for root,dirs,files in os.walk(path):
	    # print(root,dirs,files)
	    for f in files:
	    	one=os.path.join(root,f)
	    	zipFile.write(one,one[len(path):], zipfile.ZIP_DEFLATED)
	zipFile.close()
	# zipFile.writestr(zinfo_or_arcname, bytes)
def w(path):
	for root,dirs,files in os.walk(path):
	    # print(root,dirs,files)
	    for f in files:
	    	print(os.path.join(root,f))
f1()
